package org.jetlinks.pro.elastic.search.utils;

import org.jetlinks.pro.utils.ConverterUtils;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author bsetfeng
 * @since 1.0
 **/
public class TermCommonUtils {

    /**
     * 尝试转换值为集合,如果不是集合格式则直接返回该值
     *
     * @param value     值
     * @param converter 转换器,用户转换单个结果
     * @return 转换结果
     */
    public static Object tryConvertToList(Object value, Function<Object, Object> converter) {
        return ConverterUtils.tryConvertToList(value, converter);
    }

    public static <T> List<T> convertToList(Object value, Function<Object, T> converter) {
        return ConverterUtils.convertToList(value, converter);
    }

    public static List<Object> convertToList(Object value) {
        return ConverterUtils.convertToList(value);
    }

}
